package com.imooc.socketexample;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * InetAddress
 */
public class Test1 {
    public static void main(String[] args) {
        InetAddress address = InetAddress.getLoopbackAddress();
        System.out.println(address);
        System.out.println(address.getHostAddress()+":"+address.getCanonicalHostName()+":"+address.isLoopbackAddress()+":"+address.isAnyLocalAddress());
        System.out.println(address.isLinkLocalAddress());
        System.out.println(new String(address.getAddress())+"----------");
        System.out.println("######################");
        try {
            InetAddress address1 = InetAddress.getByName("localhost");
            System.out.println(address1);
            System.out.println(address1.getHostAddress()+":"+address1.getCanonicalHostName()+":"+address1.isLoopbackAddress()+":"+address1.isAnyLocalAddress());
            System.out.println(address1.isLinkLocalAddress());
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }
}
